package top.songxs.gmall.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.feign.product.CategoryFeignClient;
import top.songxs.gmall.product.vo.CategoryVo;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private CategoryFeignClient categoryFeignClient;
    @GetMapping(value = {"index","/index.html","/"})
    public String index(Model model){
        Result<List<CategoryVo>> allCategoryTree = categoryFeignClient.findAllCategoryTree();
        List<CategoryVo> list = allCategoryTree.getData();
        model.addAttribute("list",list);
        return "index/index";

    }
}
